# Go parameters
GO_CMD=go
GO_BUILD=$(GO_CMD) build
GO_CLEAN=$(GO_CMD) clean
GO_TEST=$(GO_CMD) test
GO_GET=$(GO_CMD) get
BINARY_PATH=build
BINARY_NAME=dnsmap
BINARY_UNIX=$(BINARY_NAME)_unix
BINARY_WIN=$(BINARY_NAME)_windows.exe
BINARY_DARWIN=$(BINARY_NAME)_darwin

all: clean build

build:
	$(GO_BUILD) -v -o $(BINARY_PATH)/$(BINARY_NAME)
	cp -r resources $(BINARY_PATH)/

clean:
	rm -rf $(BINARY_PATH)/

deps:
	$(GO_GET) -v -u .

# Cross compilation
build-linux:
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO_BUILD) -o $(BINARY_PATH)/$(BINARY_UNIX) -v
	cp -r resources $(BINARY_PATH)/

build-windows:
	CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO_BUILD) -o $(BINARY_PATH)/$(BINARY_WIN) -v
	cp -r resources $(BINARY_PATH)/

build-darwin:
	CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO_BUILD) -o $(BINARY_PATH)/$(BINARY_DARWIN) -v
	cp -r resources $(BINARY_PATH)/